<template>
<h1>双向绑定指令</h1>
  <input type="text" :value="info">
  {{info}}
  <hr>

  <h3>用户注册</h3>
  <input type="text" placeholder="请输入用户名" v-model="user.username">
  <input type="text" placeholder="请输入密码" v-model="user.password">
  <br>性别：
  <input type="radio" name="sex" value="1" v-model="user.sex">男
  <input type="radio" name="sex" value="0" v-model="user.sex">女
  <br>
  <button @click="reg">注册</button>

</template>


<script setup>
import {ref} from "vue";

const info = ref(666);
//定义对象用来保存用户再页面上的注册信息
const user = ref ({
  username: "张三",
  password: "213",
  sex: ""
});

const reg = () => {
  console.log(user.value);
  console.log(user.value.username);
  console.log(user.value.password);
  console.log(user.value.sex);
}


</script>


<style scoped>

</style>